package greedy;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author tongchen
 * @create 2023-03-09 8:37
 * 思路：利用贪心解决会议问题：将会议的结束时间从小到大排列出来，不断循环加入可行的队伍中；
 */
public class ConferenceForGreedy {
    public static void main(String[] args) {

    }
    public int conferenceGreedy(Conference[]programs){
        if(programs==null||programs.length==0){
            return  0;
        }
        int result=0;

        int timeLine=0;
        //对数组进行排序
        Arrays.sort(programs, new Comparator<Conference>() {
            @Override
            public int compare(Conference o1, Conference o2) {
                return 0;
            }
        });
        //对数组进行遍历放入
        for (int i = 0; i < programs.length; i++) {
            if(programs[i].start>=timeLine){
                result++;
                //不断去更迭timeLine
                timeLine=programs[i].end;
            }
        }
        return result;
    }
   public static class sorts implements Comparator<Conference> {
       @Override
       public int compare(Conference o1, Conference o2) {
           return o1.end-o2.end;
       }
   }
}
